<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //array是一个内置对象，里面有一些固定的方法。
        console.log(Array.prototype)
        Array.prototype.sum  = function() {
            var sum = 0;
            for (var i = 0;i < this.length; i++) {    //this指向调用者
                sum += this[i];
            }
            return sum;
        }
        var arr1 = new Array(11,22,33)
        //arr1调用了sum函数，故this指向arr1
        console.log(arr1.sum())
        //此处相当于实例对象
        var arr = [1,2,3]
        console.log(arr.sum());
        // 可以检验arr是否为Array的实例对象
        console.log(arr.__proto__ === Array.prototype);  //true
        console.log(Array.prototype) //查看原型对象是否存在这个新加的sum函数
    </script>
</body>
</html>